package com.jang.mapper.cases;

import com.jang.Entity.cases.CaseRuningEntity;
import com.jang.Entity.cases.ConfigEntity;
import com.jang.Entity.cases.DictEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Controller;

import java.util.List;

@Mapper
@Controller
public interface ConfigMapper {
/***环境配置****/
    @Select("SELECT * from envconfig ")
    List<ConfigEntity> getEnvConfig();

    @Select("SELECT * from envconfig where env_id=#{env_id} and delete_flag =0")
    ConfigEntity getEnvConfigById(@Param( "env_id")String env_id);

    @Insert("insert into envconfig(env_addr,env_declare)VALUES(#{env_addr},#{env_declare})")
    int insertEnvConfig(ConfigEntity configEntity);

    @Update("update envconfig set env_addr=#{env_addr},env_declare=#{env_declare} where env_id=#{env_id} and delete_flag =0")
    int updateEnvConfig(ConfigEntity configEntity);

    @Update("update envconfig set delete_flag =#{delete_flag} where env_id=#{env_id} ")
    int DelEnvConfig(ConfigEntity configEntity);
/***请求头配置*****/
    @Select("SELECT * from headerConfig where delete_flag=0")
    List<ConfigEntity> getHeaderConfig();

    @Insert("insert into headerconfig(header_key,header_value)values(#{header_key},#{header_value})")
    int insertHeaderConfig(ConfigEntity configEntity);

    @Update("update headerconfig set header_key=#{header_key},header_value=#{header_value} where header_id=#{header_id} and delete_flag =0")
    int updateHeaderConfig(ConfigEntity configEntity);

    @Select("select * from data_dict where dict_key=#{dict_key} and dict_status =0 order by dict_sort ASC")
    List<DictEntity>getDict(@Param("dict_key")String env_id);

/******测试计划配置******/
    @Select("SELECT a.*,b.project_name from test_plan a,project b where a.project_id=b.project_id ")
    List<CaseRuningEntity> getTest_plan();

    @Select("SELECT a.*,b.project_name from test_plan a ,project b where plan_id=#{plan_id} and a.project_id=b.project_id")
    CaseRuningEntity getTest_planById(@Param( "plan_id")String plan_id);

    @Insert("insert into test_plan(name,project_id)values(#{name},#{project_id})")
    int insertTestPlan(CaseRuningEntity caseRuningEntity);

    @Update("update test_plan set name=#{name},project_id=#{project_id} where plan_id=#{plan_id} and delete_flag =0")
    int updateTestPlan(CaseRuningEntity caseRuningEntity);

    @Update("update test_plan set delete_flag =#{delete_flag} where plan_id=#{plan_id} ")
    int DelTestPlan(CaseRuningEntity caseRuningEntity);
    /*****项目********/
    @Select("SELECT * from project where delete_flag=0")
    List<CaseRuningEntity> getProject();
}
